package com.springboot.others.mapper;

import com.springboot.others.entity.Customer;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CustomerMapper {

    //查询所有
    String selectAllSql = "select * from customer";

    @Select(selectAllSql)
    List<Customer> selectAll ();

    //条件查询
    List<Customer> selectByCondition (Customer customer);

    //根据id多条查询
    List<Customer> selectByIds (Integer[] integers);

    //插入一条
    String insertSql = "insert into customer set customer_id = null,store_id = #{storeId}," +
            "first_name = #{firstName},last_name = #{lastName},email = #{email}," +
            "address_id = #{addressId},active = #{active},create_date = now()," +
            "last_update = now()";
    @Insert(insertSql)
    void insertOne (Customer customer);

    //修改一条
    void updateOne (Customer customer);

    //删除一条
    String deleteSql = "delete from customer where customer_id = #{customerId}";
    @Delete(deleteSql)
    void deleteOne (Integer id);

}
